@page "/templateSetting"
@namespace SwashbucklerDiary.Rcl.Pages
@inherits ImportantComponentBase

<MyAppBar Title="@(I18n.T("Template"))"
          OnClick="NavigateToBack">
</MyAppBar>

<ScrollContainer>
    <MCard Class="mb-5"
           Elevation="0"
           Rounded="@("lg")">
        <MList Class="py-0">
            <MListItem OnClick="() => showDefaultTemplate = true">
                <MListItemIcon>
                    <MIcon>
                        space_dashboard
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    <MListItemTitle>
                        <wc-auto-scroll-text>@(I18n.T("Default template"))</wc-auto-scroll-text>
                    </MListItemTitle>
                    <MListItemSubtitle>
                        <wc-auto-scroll-text>@(I18n.T("Automatically used when adding diary entries"))</wc-auto-scroll-text>
                    </MListItemSubtitle>
                </MListItemContent>
                <MListItemAction>
                    <MIcon>chevron_right</MIcon>
                </MListItemAction>
            </MListItem>

            <MDivider Class="mx-5"></MDivider>

            <MListItem>
                <MListItemIcon>
                    <MIcon>
                        select
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    <MListItemTitle>
                        <wc-auto-scroll-text>@(I18n.T("Select template when create"))</wc-auto-scroll-text>
                    </MListItemTitle>
                    <MListItemSubtitle>
                        <wc-auto-scroll-text>@(I18n.T("Only effective when no default template is set"))</wc-auto-scroll-text>
                    </MListItemSubtitle>
                </MListItemContent>
                <MListItemAction>
                    <SettingSwitch @bind-Value="selectTemplateWhenCreate"
                                   SettingKey="@nameof(Setting.SelectTemplateWhenCreate)">
                    </SettingSwitch>
                </MListItemAction>
            </MListItem>
        </MList>
    </MCard>
    <MCard Class="mb-5"
           Elevation="0"
           Rounded="@("lg")">
        <MList Class="py-0">
            <MListItem OnClick="() => showUseTemplateMethod = true">
                <MListItemIcon>
                    <MIcon>
                        tactic
                    </MIcon>
                </MListItemIcon>

                <MListItemContent Style="flex-basis:50%;">
                    <wc-auto-scroll-text>@(I18n.T("Use Template Method"))</wc-auto-scroll-text>
                </MListItemContent>

                <MListItemContent Class="ml-2" Style="flex-basis:50%;">
                    <MListItemSubtitle>
                        <wc-auto-scroll-text class="justify-end">
                            @I18n.T(useTemplateKindItems.FirstOrDefault(it => it.Value == useTemplateMethod).Key)
                        </wc-auto-scroll-text>
                    </MListItemSubtitle>
                </MListItemContent>
                
                <MListItemAction>
                    <MIcon>chevron_right</MIcon>
                </MListItemAction>
            </MListItem>
        </MList>
    </MCard>
</ScrollContainer>

<RadioDialog @bind-Value="useTemplateMethod"
             @bind-Visible="showUseTemplateMethod"
             Title="@(I18n.T("Use Template Method"))"
             OnChange="UseTemplateMethodChanged"
             TItem="KeyValuePair<string, Shared.UseTemplateKind>"
             TItemValue="Shared.UseTemplateKind"
             Items="useTemplateKindItems">
</RadioDialog>

<SelectTemplateDialog @bind-Visible="showDefaultTemplate"
                      @bind-Tags="tags"
                      OnOK="SetDefaultTemplateAsync">
</SelectTemplateDialog>
